package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 何华树
 * Date: 2024-09-06
 * Time: 15:32
 */
class Date {
    public int year;
    public int month;
    public int day;

    public void setDay(int year, int month, int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public Date(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
        System.out.println("调用了带有三个参数的构造方法。");
    }
    public Date() {
        this(2008,8,8); //通过this调用带有三个参数的构造方法。
        System.out.println("调用了无参数的构造方法。");
    }

    public void print() {
        System.out.println(this.year +" 年 "+ this.month+" 月 "+ this.day+" 日");
    }
}
public class Test {
    public static void main(String[] args) {
        Date date = new Date(2008,8,8);
        Date date1 = new Date();
    }
}
//    public static void main1(String[] args) {
////        Date date1 = new Date();
////        Date date2 = new Date();
////        Date date3 = new Date();
////        date1.setDay(2008,8,8);
////        date2.setDay(2009,9,9);
////        date3.setDay(2010,10,10);
//    }